import pymysql
# 录入数据(多条）

try:
    con = pymysql.connect(host="localhost",user="root",password="root",db="job51")
    print(con)
    cursor = con.cursor()


    # 录入数据语句
    sql = '''
    insert into job(sname,sex,age,score) values(%s,%s,%s,%s)
    '''
    args = [('王五', 'woman', 22, 98.6), ('赵六', 'man', 21, 99.1)]

    cursor.executemany(sql,args)
    # 提交事务
    con.commit()
    print("录入成功")
except Exception as e:
    print(e)
    con.rollback()
    print("录入失败")
finally:
    # 关闭数据库连接
    con.close()
